package 二叉树序列化;

public class 二叉树序列化 {
	class TreeNode {
		int val = 0;
		TreeNode left = null;
		TreeNode right = null;

		public TreeNode(int val) {
			this.val = val;
		}
	}

	public static void main(String[] args) {

	}

	class TreeToSequence {
		public String toSequence(TreeNode root) {
			String str = "";
			if (root == null)
				return "";
			else {
				str = "(" + toSequence(root.left) + toSequence(root.right) + ")";
			}
			return str;
		}
	}

	class TreeToSequence2 {
		public String toSequence(TreeNode root) {
			if (root == null)
				return "";
			return "(" + toSequence(root.left) + toSequence(root.right) + ")";
		}
	}
}
